package com.geepi.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.geepi.dao.SearchDao;

public class LoginServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String uname = request.getParameter("uname");
		String upwd = request.getParameter("pwd");
		System.out.println("console uname: " + uname + ", pwd:" + upwd);
		try {
			int no = SearchDao.getIdByName(uname);
			System.out.println("console uname: " + uname + ", uid:" + no);			
			request.setAttribute("id", no);
			request.getRequestDispatcher("/1/IdResult.jsp").forward(request, response);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
